POV-Ray : Newsgroups : povray.advanced-users : Object Oriented POV code : Re: Object Oriented POV code Server Time
28 Jul 2024 20:19:32 EDT (-0400)
  Re: Object Oriented POV code  
From: David Wallace
Date: 10 Feb 2004 11:32:36
Message: <402907a4@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote in message
news:4025787d@news.povray.org...
> I've decided to have a go at creating a fairly complex scene file based on
lots
> of autonomous entities with simple ai and physics. So, I've been figuring
out
> tricks for writing pov scene code in an object-oriented manner.
>
> i.e. there basically needs to be some way of defining classes (I won't do
> inheritance), with member variables and functions. And some system of
creating
> and destroying these on the fly. Oh, and persistent variables.
>
> Now, I think I've actually figured out a pretty decent way to do all this,
just
> using the SDL. I'm happy to give details but I don't want to clog up this
> message with all that info.
>
> But anyway, the reason I'm posting: I was just wondering has anyone done
this
> before? Either within the SDL, or as a modification to pov to support
simple
> data structures and function callbacks?
>
> Oh, and do you think it should be oriented or orientated? ;)
>
> -- 
> Tek
> www.evilsuperbrain.com
>
>
My principal "object" is the #include file.  Each object definition,
including macros, variables, etc. can be placed in this file.

If you want a macro to use the object, just use the filename as a string
parameter:

#macro ObUser(iFile, oFile)
    #include iFile
    #open oFile
    ...
    #write oFile, Data
    ...
    #close oFile
#end

I use this tactic frequently.  Macros that would otherwise use a large
number of parameters are greatly simplified by this method.  Macros,
functions, and primitives that might not otherwise be available as macro
parameters can be provided for this way.

#include files also carry one extra benefit: you can add descriptive
comments and variable names that make code reading easier

Try it some time.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.